<script setup lang="ts">
import {useRoute} from "vue-router";
import {onMounted, ref} from "vue";
import {getNewsDetail} from "@/api/newsApi.ts";

const route = useRoute();
const id = route.params.id;

const news = ref([]);
const fetchNewsData = () => {
  getNewsDetail({
    id: id
  }).then(res => {
    news.value = res.data
  })
}

onMounted(() => {
  fetchNewsData();
});

</script>

<template>
  <div class="news">
    <div class="title">
      {{ news.title }}
    </div>
    <div class="content" v-html="news.content" />
  </div>
</template>

<style scoped lang="less">
.news {
  padding: 10px;

  .title {
    margin-bottom: 25px;
    font-weight: bold;
    font-size: 18px;
  }
}
</style>